﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Common
{
	[Serializable]
	/// <summary>
	/// Provides an internal structure to sort the query parameter
	/// </summary>
	public class QueryParameter
	{
		private string name = null;
		private string value = null;

		public QueryParameter(string name, string value)
		{
			this.name = name;
			this.value = value;
		}

		public string Name
		{
			get
			{
				return name;
			}
		}

		public string Value
		{
			get
			{
				return value;
			}
		}
	}

	/// <summary>
	/// Comparer class used to perform the sorting of the query parameters
	/// </summary>
	public class QueryParameterComparer : IComparer<QueryParameter>
	{
		#region IComparer<QueryParameter> Members

		public int Compare(QueryParameter x, QueryParameter y)
		{
			if (x.Name == y.Name)
			{
				return string.Compare(x.Value, y.Value);
			}
			else
			{
				return string.Compare(x.Name, y.Name);
			}
		}

		#endregion
	}

}
